package com.example.yingjiguanli_demo.pojo;

import lombok.Data;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@Data
public class UserRoleDTO {
    private String username;
    private String uName;
    private Integer status;
    private String roleName;
    private LocalDateTime createdAt; // 创建时间
    private List<String> permissions;  // 角色对应的权限列表
    // 转换查询结果中的角色名称为权限列表
    public void setPermissions(String roleNames) {
        if (roleNames != null && !roleNames.isEmpty()) {
            // 如果是多个角色，通过逗号分隔
            this.permissions = Arrays.asList(roleNames.split(","));
        } else {
            this.permissions = new ArrayList<>();
        }
    }
}

